#ifndef __BUCKET_H__
#define __BUCKET_H__

#include "util/Pool.h"

class Bucket {
    
 public:
    NEW_DELETE_OPERATORS_H(Bucket,NoSuper);
    Bucket (const char* _name);
    Bucket (const char* _name, Bucket* _rollbackRecipient);
    ~Bucket ();
    void   vote ();
    void   unvote ();
    // allows you to choose whether the bucket succeeds in its vote
    void   elect (bool transactional = false);
    bool   getVoteStatus ();
    const char* getName ();

    uint64 peek () { return value; }
    uint64 peekSpeculative () { return specValue; }

 private:
    void   rollback ();
    void   commit ();
    
    bool   rollbackEnabled;
    Bucket* recipient;
    const char*  outputName;
    uint64 value;
    uint64 specValue;
    bool   voted;
    
    friend class StatisticsCollection;
};

#endif
